﻿using System;
using System.Collections.Generic;

/// <summary>
/// Summary description for MyProgram
/// </summary>
/// 
namespace CargoNet.Service
{
    class MyProgram
    {
       // static CargoService.ServiceGate gate;

        //static void Main(string[] args)
        //{
        //    gate = new ServiceGate();
        //    gate.CookieContainer = new System.Net.CookieContainer();
        //    gate.AllowAutoRedirect = true;

        //    LoginResult lr = gate.Login("admin", "admin");
        //    if (lr.Code != ErrorCode.OK)
        //    {
        //        Console.WriteLine("Error during login: {0}", lr.Message);
        //        return;
        //    }

        //    InsertAPInvoice();

        //    Console.WriteLine("Press ENTER to exit.");
        //    Console.ReadLine();
        //}
        static void InsertAPInvoice()
        {
           // GraphAPInvoiceEntry graph = new GraphAPInvoiceEntry();

        //    RowCurrencyInfo RCuryInfo = new RowCurrencyInfo();
        //    RCuryInfo.CuryID = "USD";
        //    graph.Viewcurrencyinfo = new View();
        //    graph.Viewcurrencyinfo.InsertRows = new object[] { RCuryInfo };
        //    graph.GraphState = GraphObjectState.ClearUnload;
        //    graph = (GraphAPInvoiceEntry)gate.Process(graph);
        //    RCuryInfo = (RowCurrencyInfo)graph.Viewcurrencyinfo.InsertRows[0];

        //    RowAPInvoice RInv = new RowAPInvoice
        //    {
        //        CuryInfoID = RCuryInfo.CuryInfoID,
        //        DocType = "INV",
        //        DocDate = Convert.ToDateTime("02.01.2008"),
        //        FinPeriodID = "012008",
        //        VendorID = "BANAFIDE",
        //        InvoiceNbr = "Vendor Refference",
        //        CuryID = RCuryInfo.CuryID,
        //        TermsID = "30D",
        //        DocDesc = "Document Description",
        //        APAccountID = "200005",
        //        APSubID = "US000000000",
        //        CuryOrigDocAmt = (decimal)1000,
        //        InvoiceDate = Convert.ToDateTime("02.01.2008"),
        //        Hold = false
        //    };

        //    RowAPTran RTran = new RowAPTran
        //    {
        //        CuryInfoID = RCuryInfo.CuryInfoID,
        //        AccountID = "740000",
        //        SubID = "US000000000",
        //        Qty = (decimal)1,
        //        CuryTranAmt = (decimal)1000,
        //        CuryUnitCost = (decimal)1000,
        //        TranDesc = "Transaction Description",
        //        TranDate = Convert.ToDateTime("02.01.2008")
        //    };

        //    graph.ViewDocument = new View
        //    {
        //        SelectAction = graph.ActionSave,
        //        InsertRows = new object[] { RInv },
        //        SelectParameters = new object[] { RInv.DocType },
        //        SelectSortColumns = new string[] { "DocType", "RefNbr" },
        //        SelectSearches = new object[] { RInv.DocType, " <NEW>" },
        //        SelectMaxRows = 1
        //    };

        //    graph.ViewTransactions = new View
        //    {
        //        InsertRows = new object[] { RTran },
        //        InsertDiscardResults = true
        //    };

        //    graph.GraphState = GraphObjectState.LoadUnload;
        //    graph = (GraphAPInvoiceEntry)gate.Process(graph);

        //    Object[] o = (Object[])graph.ViewDocument.SelectRows[0];
        //    RInv = (RowAPInvoice)o[0];
        //    graph = new GraphAPInvoiceEntry();
        //    graph.ViewDocument = new View
        //    {
        //        UpdateRows = new object[] { RInv },
        //        UpdateDiscardResults = true,
        //        SelectAction = graph.Actionrelease
        //    };
        //    graph.GraphState = GraphObjectState.LoadUnload;
        //    gate.Process(graph);
        }
    }
}
